<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>自助接单（派单中）</title>
		<!--标准mui.css，公共样式-->
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/iconfont/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="../css/public.css"/>
		<link rel="stylesheet" type="text/css" href="../css/self_help_order.css"/>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left color6"></a>
			<h1 class="mui-title color6">
				<div class="mui-input-row">
				    <input type="search" placeholder="老司机代驾">
					<a class="iconfont mui-icon icon-shuaxin" id="refresh"></a>
				</div>
			</h1>
		</header>
		<div class="mui-content">			
			<div class="mui-text-center p_tb20">
				<p class="colorP">请稍候正在为您联络司机...</p>
			</div>
			<form class="mui-input-group">
			    <div class="mui-input-row b_b1">
			        <label class="m_r10"><span class="iconfont mui-icon font22 colorP">&#xe603;</span></label>
			        <input type="text" class="mui-input-clear mui-pull-left" id="initial_position" placeholder="请输入上车地址" value="中心路幸福居">
			    </div>
			    <div class="mui-input-row m_t10">
			        <label class="m_r10"><span class="iconfont mui-icon font22 color_orange">&#xe67d;</span></label>
			        <input type="number" class="w80 mui-pull-left" id="phone_num" placeholder="请输入手机号" value="12345678900">
			    	<!--<span class="mui-badge mui-btn-grey mui-pull-right b_r8 p_tb10 p_lr15">此号码为新用户</span>-->
			    </div>
			    <div class="mui-input-row b_b1">
			        <label class="m_r10"><span class="iconfont mui-icon font22 color_blue">&#xe624;</span></label>
			        <input type="text" class="w80 mui-pull-left" id="initial_position" value="2017-03-16  10:14">
			    </div>
			</form>
			<div class="mui-text-center p_tb20">
				<h4 class="p_tb10">预计<span id="second_show" class="color_orange font20">80</span>秒派单完成</h4>	
				<p>如派单成功，司机会电话联系您</p>
			</div>
		</div>
	</body>
	<!-- Mui core JavaScript-->
	<script type="text/javascript" src="../js/mui.min.js"></script>
	<script type="text/javascript" src="../js/appconfig.js"></script>
	<script type="text/javascript" src="../js/jquery-2.2.4.min.js"></script>
	<script src="../js/public.js"></script>
	<script type="text/javascript">
		//倒计时start
		var intDiff = parseInt(80);//倒计时总秒数量
		function timer(intDiff){
		    window.setInterval(function(){
		    var day=0,
		        hour=0,
		        minute=0,
		        second=0;//时间默认值        
		    if(intDiff > 0){
		        second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);		        
		    	} else { 
					location.href="driver's_orders.html"; 
			} 
		    if (second <= 9) second = '0' + second;
			    $('#second_show').html('<s></s>'+second+'');		    
			    intDiff--;			    		    
		    }, 100);		    
		} 
		$(function(){
		    timer(intDiff);		   
		});
		//倒计时end
		
		document.addEventListener( "plusready", onPlusReady, false );
		// 扩展API加载完毕，现在可以正常调用扩展API
		function onPlusReady() {
			plus.geolocation.getCurrentPosition( function ( p ) {
				$('#initial_position').val(p.address.poiName);
			}, function ( e ) {
			//	alert( "Geolocation error: " + e.message );
			} );
		}
		
		//判断起始位置是否有值
		$('#initial_position').on('blur',function(){
			if($(this).val() == ""){
				mui.toast('请输入起始位置');return;
			} else {
				//判断起始位置和电话号码都没有值
				if($('#initial_position').val() !="" && $('#phone_num').val()!=""){
					$('#call_driver').attr('disabled',false);
				}
			}
		})
		
		//判断电话号码格式和
		$('#phone_num').on('blur',function(){
			if($(this).val() == ""){
				mui.toast('请输入电话号码');return;
			}else{
				if(!phone_num.test($(this).val())){
					mui.toast('请输入正确的手机号');return;
				} else {
					if($('#initial_position').val() !="" && $('#phone_num').val()!=""){
						$('#call_driver').attr('disabled',false);
					}
				}
			}
		})
		//判断起始位置和电话号码都没有值
//		if($('#initial_position').val() !="" && $('#phone_num').val()!=""){
//			$('#call_driver').attr('disabled',false);
//		}
		//呼叫司机
		$('#call_driver').on('tap',function(){
			plus.device.dial($('#phone_num').val(),true);
		})
	</script>
</html>